import { mapGetters, mapMutations } from 'vuex'
export default {
	computed: {
		...mapGetters(['isLogin', 'getState', 'configComplete', 'userInfo'])
	},
	data() {
		return {
			
		}
	},
	onLoad() {
		// const pages = getCurrentPages();  
		// const page = (pages[pages.length - 1]).route;
		// if(!this.isLogin && page !== 'pages/wxlogin/wxlogin' && page !== 'pages/login/login' && page !== 'pages/index/index') {
		// 	uni.reLaunch({
		// 		url: '/pages/wxlogin/wxlogin'
		// 	})
		// 	return
		// }
		if(this.configComplete) {
			const globalConfig = this.getState('globalConfig')
			if(this.config) {
				for (let key in this.config) {
					this.config[key] = globalConfig[key]
				}
			}
			if(this.pageInit) {
				this.pageInit()
			}
		}
	},
	onShow() {
		
	},
	methods: {
		...mapMutations(['setState', 'logout'])
	},
	watch: {
		configComplete(value) {
			if(value) {
				const globalConfig = this.getState('globalConfig')
				if(this.config) {
					for (let key in this.config) {
						this.config[key] = globalConfig[key]
					}
				}
				if(this.pageInit) {
					this.pageInit()
				}
			}
		}
	}
}